import { Injectable } from '@angular/core';
import {Observable} from "rxjs/Observable";
import {DamAPI} from "../../peach-constants";
import {RequestUtil} from "../../../../util/request-util";
import {MsgResult} from "../../../../models/msg-result";

@Injectable()
export class TraceAnalyzeService {

  constructor(
    private requestUtil: RequestUtil
  ) { }

  /**
   * 账户可看站点
   * @returns {Observable<MsgResult>|any}
   */
  getUserSite():Observable<MsgResult>{
    return this.requestUtil.get(DamAPI.getUserSite);
  }
  getTraceAnalyze(siteCode,dataType):Observable<MsgResult>{
    let params = "siteCode=" + siteCode+'&dataType='+dataType;
    return this.requestUtil.get(DamAPI.getTraceAnalyze,params);
  }
  getTraceByTime(siteCode,occurTime,dataType):Observable<MsgResult>{
    let params = "siteCode=" + siteCode+'&occurTime='+occurTime+'&dataType='+dataType;
    return this.requestUtil.get(DamAPI.getTraceAnalyze,params);
  }
  getRealTrace(siteCode,occurTime):Observable<MsgResult>{
    let params = "siteCode=" + siteCode+'&occurTime='+occurTime;
    return this.requestUtil.get(DamAPI.getRealTrace,params);
  }
  getTraceNum(siteCode,occurTime):Observable<MsgResult>{
    let params = "siteCode=" + siteCode+'&occurTime='+occurTime;
    return this.requestUtil.get(DamAPI.getTraceNum,params);
  }
  /**
   * 根据类型获取站点信息
   * @param pointType
   */
  getMapSiteData(pointType):Observable<MsgResult> {
    let params = "format=json&pointType=" + pointType;
    let SiteUrl = DamAPI.mapSiteInfo;
    if (pointType == "raiseDustNewSite") {
      SiteUrl = DamAPI.mapDustSiteInfo;
    }
    return this.requestUtil.get(SiteUrl,params);
  }
}
